/*
 * auipopupwindow.h
 *
 *  Created on: 2012-7-24
 *      Author: Yangde
 */

#ifndef AUIPOPUPWINDOW_H_
#define AUIPOPUPWINDOW_H_

#include "wx/popupwin.h"
#include "auimenubar.h"
#include "wx/dc.h"

class auiMenuItem;
class auiMenu;

class auiPopupWindow :public wxPopupWindow{
public:
	auiPopupWindow(wxWindow * parent, auiMenu* menu);
	virtual ~auiPopupWindow();
	virtual void Popup(wxWindow *focus,bool selectFirst=false);
	virtual void ProcessLeftDown(const wxPoint& pos);
	virtual void ProcessLeftUp(const wxPoint& pos);

	void MainMenuAdjustPosition(const wxPoint& ptOrigin, int menuBarHight);
	void SubMenuAdjustPosition(const wxRect& rect);

	void OnLeftDown(wxMouseEvent& event);
	void OnLeftUp(wxMouseEvent& event);
	void OnRightDown(wxMouseEvent& event);
	void OnMouseMove(wxMouseEvent& event);
	void ProcesMouseMove(const wxPoint& pos);
	void Dismiss();
	void calcClientSize();
	void OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event));



	int GetItemByPosition(const wxPoint& pt);
	wxRect GetItemRect(int index);

#ifdef __WXMSW__
    void OnIdle(wxIdleEvent& WXUNUSED(event)) { }
#endif

	void OnPaint(wxPaintEvent& evt);
	void DrawMenuItem(auiMenuItem* item, wxDC& dc,wxRect& rect);
	void DrawArrow(wxDC& dc,wxRect& rect);
	auiMenu* m_menu;

	int t_margin;
	int b_margin;
	int l_margin;
	int r_margin;

	int t_padding;
	int b_padding;
	int l_padding;/*include icon size*/
	int r_padding;
    int font_height;
    int separator_height;
    int menu_item_hight;
    int menu_item_width;

    wxPoint oldMousePos;

	DECLARE_EVENT_TABLE()
};

#endif /* AUIPOPUPWINDOW_H_ */
